package com.project.dhCamera.handler;

import com.project.dhCamera.service.OutHandlerMethod;
import org.springframework.stereotype.Component;

/**
 * @author Sweey Zhang
 * @description
 * @date 2021/7/20 12:08
 */
@Component
public class DefaultOutHandlerMethod implements OutHandlerMethod {
    /**
     * 任务是否异常中断，如果
     */
    public boolean isBroken=false;

    @Override
    public void parse(String id,String msg) {
        //过滤消息
        if (msg.indexOf("fail") != -1) {
            System.err.println(id + "任务可能发生故障：" + msg);
            System.err.println("失败，设置中断状态");
            isBroken=true;
        }else if(msg.indexOf("miss")!= -1) {
            System.err.println(id + "任务可能发生丢包：" + msg);
            System.err.println("失败，设置中断状态");
            isBroken=true;
        }else {
            isBroken=false;
            System.err.println(id + "消息：" + msg);

        }

    }

    @Override
    public boolean isbroken() {
        return isBroken;
    }

}
